package dev.tools;

import com.google.common.base.Joiner;

public class Utils{
    private static final String CAMEL_CASE_SPLITTER_PATTERN = "(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])";

    private Utils(){
    }

    public static String camelToTitleCase(String s, String... affixes) {
        for(String affix : affixes)
            s = s.replace(affix, "");

        return Joiner.on(" ").join(s.split(CAMEL_CASE_SPLITTER_PATTERN));
    }

    public static String camelToTitleCase(Object o, String... affixes) {
        if (o instanceof String)
            return camelToTitleCase(o.toString(), affixes);

        if (o instanceof Class)
            return camelToTitleCase(((Class) o).getSimpleName(), affixes);

        return camelToTitleCase(o.getClass(), affixes);
    }
}
